﻿@{
    Layout = null;
    DeliveryManage.Models.ReturnMsgModel returnMsg = ViewBag.ReturnMsgModel;
    Dictionary<int, string> dicDeliveryWay = ViewData["dicDeliveryWay"] as Dictionary<int, string>;
    Dictionary<int, string> dicStatus = ViewData["dicStatus"] as Dictionary<int, string>;
}
@model DeliveryManage.Model.Pro_Orders
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>所有订单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" href="~/Content/font.css">
    <link rel="stylesheet" href="~/Content/framemain.css">
    <link rel="stylesheet" href="~/Content/pagination.css" />
    <script type="text/javascript" src="~/Content/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="~/Scripts/common.js"></script>
    <script type="text/javascript" src="~/Scripts/framemain.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
    <style>
        .layui-table img {
            max-width: inherit;
        }

        .pro-img {
            border-radius: 5px;
            border: 1px solid #f2f2f2;
        }
    </style>
</head>
<body>
    @using (Html.BeginForm("OrderList", "Order", FormMethod.Get))
    {
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="javascript:;">首页</a>
                <a><cite>所有订单</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        if (returnMsg.code == 200)
        {
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card layui-form">
                            <div class="layui-card-header">
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" class="layui-input" name="keywords" id="keywords" value="@ViewBag.Keyword" placeholder="请输入订单号或客户名称电话" />
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="hidden" name="pageSize" id="pageSize" value="@ViewData["pageSize"]" />
                                    <input type="hidden" name="page" id="page" value="@ViewData["page"]" />
                                </div>
                                <div class="layui-inline layui-show-xs-block">订单状态:</div>
                                <div class="layui-inline layui-show-xs-block" style="width:100px">
                                    @Html.DropDownListFor(m => m.Status, ViewData["StatusList"] as SelectList, new { @class = "layui-input layui-select", id = "status", @lay_filter = "status" })
                                </div>
                                <input type="submit" value="&#xe615; 查询" class="layui-btn layui-btn-select layui-icon" />
                            </div>
                            <div class="layui-card-body ">
                                <table class="layui-table layui-form">
                                    <thead>
                                        <tr>
                                            <th width="2%">
                                                <input type="checkbox" lay-filter="checkall" id="checkalll" name="checkalll" lay-skin="primary">
                                            </th>
                                            <th>订单号</th>
                                            <th>客户姓名</th>
                                            <th>客户电话</th>
                                            <th>订单金额(￥)</th>
                                            <th>发货方式</th>
                                            <th>订单状态</th>
                                            <th>申报人</th>
                                            <th>申录时间</th>
                                            <th>订单备注</th>
                                            <th width="5%">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @{
                                            if (ViewBag.OrderList.Count > 0)
                                            {
                                                foreach (DeliveryManage.Model.Pro_Orders item in ViewBag.OrderList)
                                                {
                                                    <tr>
                                                        <td>
                                                            <input type="checkbox" name="chkid" lay-skin="primary" class="checkall" />
                                                            <input type="hidden" name="hidid" value="@item.Id" />
                                                        </td>
                                                        <td>@item.OrderNo</td>
                                                        <td>@item.CustomerName</td>
                                                        <td>@item.CustomerTel</td>
                                                        <td>@item.TotalAmount ￥</td>
                                                        <td>@dicDeliveryWay[item.DeliveryWay]</td>
                                                        <td>
                                                            @{
                                                                if (item.Status == 0)
                                                                {
                                                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-radius">@dicStatus[(int)item.Status]</button>
                                                                }
                                                                else if (item.Status == 1)
                                                                {
                                                                    <button type="button" class="layui-btn layui-bg-cyan layui-btn-radius">@dicStatus[(int)item.Status]</button>
                                                                }
                                                                else if (item.Status == 2)
                                                                {
                                                                    <button type="button" class="layui-btn layui-bg-blue layui-btn-radius">@dicStatus[(int)item.Status]</button>
                                                                }
                                                                else if (item.Status == 3)
                                                                {
                                                                    <button type="button" class="layui-btn layui-bg-red layui-btn-radius">@dicStatus[(int)item.Status]</button>
                                                                }
                                                                else if (item.Status == 4)
                                                                {
                                                                    <button type="button" class="layui-btn layui-bg-green layui-btn-radius">@dicStatus[(int)item.Status]</button>
                                                                }
                                                                else
                                                                {
                                                                    <button type="button" class="layui-btn layui-bg-orange layui-btn-radius">@dicStatus[(int)item.Status]</button>
                                                                }
                                                            }
                                                        </td>
                                                    <td>
                                                        @{
                                                            if (MvcApplication.UserList.ContainsKey(item.EmployeeId))
                                                            {
                                                                @MvcApplication.UserList[item.EmployeeId].Nickname
                                                            }
                                                        }
                                                    </td>
                                                    <td>@(item.Created.Value.ToString("yyyy-MM-dd HH:mm:ss"))</td>
                                                    <td>@item.Remark</td>
                                                    <td>
                                                        <div class="layui-btn-container">
                                                            <a title="查看订单详情" class="layui-btn layui-btn-xs" onclick="xadmin.open('订单详情','/Order/DetailOrder?action=View&OrderId=@item.Id',1200,600)" href="javascript:;"><i class="layui-icon">&#xe615;</i>详情</a>
                                                        </div>
                                                    </td>
                                                </tr>
                                            }
                                        }
                                        else
                                        {
                                            <tr>
                                                <td colspan="11" align="center" height="200"><img src="~/images/nodata.png" style=" width: 10%; " /><br /> 暂无相关数据</td>
                                            </tr>
                                        }
                                        }

                                    </tbody>
                                </table>
                            </div>

                            <div class="pagelist">
                                <div id="PageContent" class="default">@Html.Raw(ViewBag.PageInnerHtml)</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        }
    }

    <script type="text/javascript">
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        // 监听全选
        form.on('checkbox(checkall)', function (data) {
            if (data.elem.checked) {
                $('tbody .checkall').prop('checked', true);
            } else {
                $('tbody .checkall').prop('checked', false);
            }
            form.render('checkbox');
        });
        //切换分页大小
        form.on('select(selectpage)', function (data) {
            var data = thisdata();//搜索条件
            locations(data);
        })
    });

    //搜索参数函数
    function thisdata()
    {
        var data = {
            pageCount: $('.txtPageCount').val(),
            pageSize: $("select[name=select_page").val(), //获取到所选的id
            keywords: $('#keywords').val(),
            uid: $('#uid').val(),
        };

        if (data.pageCount=="") {
            data.pageCount= @ViewData["page"];
        }
        return data;
    }

    //调用页面方法
    function locations(data) {
        window.location.href = '/Order/OrderList?page=' + data.pageCount + "&pageSize=" + data.pageSize + '&keywords=' + data.keywords + '&uid=' + data.uid;
        }

      $(function () {
            //操作提示
            if (@returnMsg.code == 400) {
                layer.msg('@returnMsg.msg', { icon: 5, title: '提示' }, function (index) {
                  layer.close();
                })
            }

            //跳转页
            $("#locationPageBtn").click(function () {
                var data = thisdata();//搜索条件
                locations(data);
            });
        })
    </script>
</body>
</html>
